﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace NClass.Core.HtmlRepresentation
{
    public class HtmlDocument:HtmlDocumentBuilder
    {
        private FileInfo m_file = null;
        private string m_htmlCode = string.Empty;
        private Project m_project = null;

        public HtmlDocument(string name):base()
        {
            m_file = new FileInfo(name);
            m_project = new Project();
        }

        public HtmlDocument(string name, Project project)
            : base()
        {
            m_file = new FileInfo(name);
            m_project = project;
        }

        private HtmlDocument()
        { }

        public void Save()
        {
            if (m_file.Exists)
            {
                m_file.Delete();        
            }
            StreamWriter stream = new StreamWriter(m_file.OpenWrite(), Encoding.Unicode);
            stream.Write(Build());
            stream.Close();
        }

        public string Build()
        {
           return  Build(m_project);
        }
    }
}
